<template>
  <div style="height:100%;">
    <div class='detail content' v-show="content!==''" v-html="content">
    </div>
    <iframe :src="src" v-show="src!==''" style="height:100%;width:100%;"></iframe>
  </div>
</template>

<script type="text/ecmascript-6">
import { mapState } from 'vuex';
export default {
  data: () => {
    return {
      content: '',
      src: ''
    }
  },
  methods: {
  },
  created: function () {
    let self = this
    this.$store.commit('changeHeader', {
      left: '返回',
      right: '',
      middle: self.bannerInfo.newsTitle,
      ifshow: true,
      leftAction: '-1',
      leftIcon: 'leftIcon',
      rightAction: '',
      rightIcon: ''
    });
    if (self.bannerInfo.newsTypeId !== 4) {
      self.content = self.bannerInfo.newsContent
    } else {
      self.src = JSON.parse(self.bannerInfo.newsContent).linkUrl
    }
    return false;
    let content = {
      'newsId': self.newsInfo.newsId
    }
    let data = this.$utils.getUserContent(content);
    this.$store.commit('showLoading');
    this.$http.post(this.$RS.newsDetail, data).then(
      function (res) {
        // 响应成功回调
        this.$store.commit('closePop');
        res = res.body;
        console.log(res);
        if (res.code === 1000) {
          if (res.content.newsTypeId !== 4) {
            self.content = res.content.content
          } else {
            self.src = JSON.parse(res.content.content).linkUrl
          }
        } else {
          console.log('out');
          this.$store.commit('closePop');
          this.$store.dispatch('showTx', { text: res.message });
        }
      },
      function (err) {
        this.$store.commit('closePop');
        // 响应错误回调
        this.$store.dispatch('showTx', { text: err.message || '网络错误，请重试' });
      }
    );
  },
  computed: mapState(['loginData', 'bannerInfo'])
}
</script>

<style lang="stylus">
@import '../../stylus/base.styl';
.width-fulls
  width: 100%;
.margin-t3
  margin-bottom: f_times(1);
.font-color-black
  color: #333;
.ticket-height
  height: f_times(3.5);
.detail
  background-color: #fff;
  padding: f_times(1);
p
  display: block;
  -webkit-margin-before: f_times(0.5);
  -webkit-margin-after: f_times(0.5);
  -webkit-margin-start: 0px;
  -webkit-margin-end: 0px;
  line-height: f_times(1.2);
  font-size: f_times(1.05);
  color: #333;
.content
  padding: f_times(1) f_times(1) 0 f_times(1);
  text-align: justify;
.content img
  max-width: 100% !important;
</style>

